import request from '@/axios';
import {baseUrl} from '@/config/env';

export const list = (data) => {
    return request({
            url: baseUrl + '/start/actBusiness/pageBusiness',
            method: 'get',
            params: data
        }
    )
}
/**
 * 查询正在运行中的业务
 * @param data
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export const pageRunningBusiness = (data) => {
    return request({
            url: baseUrl + '/start/actBusiness/pageRunningBusiness',
            method: 'get',
            params: data
        }
    )
}
/**
 * 获取业务详情
 * @param businessId
 * @returns {Promise<AxiosResponse<any>> | *}
 */
export const getBusinessDetailByBusinessId = (businessId) => {
    return request({
            url: baseUrl + '/start/actBusiness/getBusinessDetailByBusinessId/' + businessId,
            method: 'get',
        }
    )
}


/**
 * 启动流程
 * @param modelId
 * @param data
 * @returns {AxiosPromise}
 */
export const start = (modelId, data) => {
    return request({
            url: baseUrl + '/start/actBusiness/start/' + modelId,
            method: 'post',
            data: data
        }
    )
}
/**
 * 启动流程
 * @param modelId
 * @param data
 * @returns {AxiosPromise}
 */
export const userStartAct = (modelId, data) => {
    return request({
            url: baseUrl + '/start/actBusiness/userStartAct/' + modelId,
            method: 'post',
            data: data
        }
    )
}
/**
 * 启动流程并且提交表单数据
 * @param modelId
 * @param tableId
 * @param data
 * @returns {*}
 */
export const startActivitAutoFullForm = (modelId, tableId, data) => {
    return request({
            url: baseUrl + '/start/actBusiness/startActivitAutoFullForm/' + modelId + "/" + tableId,
            method: 'post',
            data: data
        }
    )
}

//
// export const updateById = (data) => {
//     return request({
//             url: baseUrl + '/actProcessModel/updateById',
//             method: 'put',
//             data: data
//         }
//     )
// }
export const deleteById = (id, data) => {
    return request({
            url: baseUrl + '/start/actBusiness/deleteById/' + id,
            method: 'delete',
            data: data
        }
    )
}
//
// export const getActModelConfigDetail = (id) => {
//     return request({
//             url: baseUrl + '/actProcessModel/getActModelConfigDetail/' + id,
//             method: 'get',
//         }
//     )
// }
//
// export const saveModelEditorSource = (id, data) => {
//     return request({
//             url: baseUrl + '/actProcessModel/saveModelEditorSource/' + id,
//             method: 'post',
//             data: data
//         }
//     )
// }
//
const actBusinessApi = {
    start,
    getBusinessDetailByBusinessId,
    pageRunningBusiness,
    startActivitAutoFullForm,
    userStartAct
}
export default actBusinessApi
